using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CheckPoint : MonoBehaviour
{
    public GameObject _respawnPoint;
    public GameObject _waterSurfaceCheck;
    public float _savedSpeed;
    public float _savedHeight;
    private int _key;

    public int Key { get => _key; set => _key = value; }

    private void Start()
    {
        _respawnPoint.GetComponent<SpriteRenderer>().enabled = false;
        _waterSurfaceCheck.GetComponent<SpriteRenderer>().enabled = false;
    }

    private void Update()
    {

    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.transform.tag == "Player")
        {
            #region Save
            _savedHeight = Mathf.Max(_waterSurfaceCheck.transform.position.y + transform.position.y, AirCurtain.Instance.Height);
            _savedSpeed = AirCurtain.Instance.CurrectSpeed;
            SaveLoadManager.Instance.Save(Key);
            gameObject.SetActive(false);
            #endregion
        }
    }
}
